#include<iostream>
#include<vector>
#include<random>
#include<ctime>
#include "QuickSort.h"
using namespace std;

int main(){
    vector<int> v1;
    int L1;
    clock_t begin1, end1, begin2, end2;
    double t1, t2;
    
    cout << "Enter the length of a vector: ";
    cin >> L1;
    
    for(int i = 0; i < L1; i++){
        v1.push_back(rand()%L1);
    }
    
    if(L1 > 1 && L1 <= 10){
        insertion_sort(v1);
        cout << "The sorted vector is " << endl;
        for(int i = 0; i < L1; i++){
            cout << v1[i] <<" " ;
        }
        cout << endl;
        return 0;
    }
    
    cout << "The array is: " << endl;
    for(int i = 0; i < L1; i++){
        cout << v1[i] <<" " ;
    }
    cout << endl;
    
    begin1 = clock();
    quick_sort(v1, 0, L1-1);
    end1 = clock();
    t1 = end1 - begin1;
    cout << "The initially sorted vector is: " << endl;
    for(int i = 0; i < L1; i++){
        cout << v1[i] <<" " ;
    }
    cout << endl;
    
    begin2 = clock();
    median3sort(v1, 0, L1-1);
    end2 = clock();
    t2 = end2 - begin2;
    cout << "The median-three sorted vector is: " << endl;
    for(int i = 0; i < L1; i++){
        cout << v1[i] <<" " ;
    }
    cout << endl;
    
    cout << "The time of the initial quicksort is: " << t1 << endl;
    cout << "The time of the mediansort is: " << t2 << endl;
}
